package com.fneuch.mwg.rules.dice;

import com.fneuch.mwg.rules.Probability;

public class RerollProbability implements Probability {
	
	private Probability ofProbability;

	public RerollProbability(Probability diceProbability) {
		super();
		this.ofProbability = diceProbability;
	}
	
	/* (non-Javadoc)
	 * @see com.fneuch.game.dice.Probability#ofNumber(int)
	 */
	@Override
	public int ofNumber(int number) {
		return ofProbability.ofNumber(number);
	}
	
	/* (non-Javadoc)
	 * @see com.fneuch.game.dice.Probability#over(int)
	 */
	public int over(int number) {
		int probability = ofProbability.over(number);
		double calcule =  probability != 100 ?
				probability + (100-probability)*probability/100
				: probability;		
		return (int) Math.round(calcule);
	}

	/* (non-Javadoc)
	 * @see com.fneuch.game.dice.Probability#under(int)
	 */
	@Override
	public int under(int number) {
		int probability = ofProbability.under(number);
		double calcule =  probability != 100 ?
				probability + (100-probability)*probability/100
				: probability;		
		return (int) Math.round(calcule);
	}
}
